package com.synjones.ui.secondScreen;

import android.app.Presentation;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.synjones.entry.SignPerson;
import com.synjones.idcardusb_reader.R;
import com.synjones.ui.FirstScreenRouter;
import com.synjones.ui.SecondScreenRouter;
import com.synjones.ui.lunch.LunchSecondScreen;

import java.util.ArrayList;
import java.util.List;


public class SecondScreen extends Presentation implements SecondScreenRouter {

    private FirstScreenRouter firstScreenRouter;

    private FrameLayout container;
    private List<View> pages = new ArrayList<>();

    public SecondScreen(Context outerContext, Display display) {
        super(outerContext, display);
        firstScreenRouter = (FirstScreenRouter) outerContext;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second_screen);
        container = (FrameLayout) findViewById(R.id.secondContainer);
        gotoWelcome();
    }



    @Override
    public void gotoWelcome() {
        clearTopPage();
        LunchSecondScreen lunch = new LunchSecondScreen(getContext(), firstScreenRouter, this);
        container.addView(lunch, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }

    @Override
    public void gotoRecognize(boolean signBySelf) {
        clearTopPage();
    }

    @Override
    public void gotoCheck(SignPerson signPerson) {

    }

    @Override
    public void showToast(String msg, int color) {

    }

    private void clearTopPage(){
        for (View view: pages) {
            container.removeView(view);
        }
        pages.clear();
    }

    public void release(){

    }
}
